export default {
    namespaced: true,
    // 数据
    state: {
        isShowToast: false,
        //提示内容
        toastMsg: '',
        //提示类型 (success danger warning)
        toastType:''
    },
    getters: {
    },
    // 同步
    mutations: {
        changeIsShowToast(state, payload) {
            state.isShowToast = payload.show
            
            if (payload.show) {
                state.toastMsg = payload.msg;
                state.toastType = payload.type
            }
        }
    },
    // 异步
    actions: {
        asyncIsShowToast(context, payload) {
            // 调用mutations方法 context.commit("")
            // 1.显示提示框
            context.commit("changeIsShowToast", payload)
            // 2.自动隐藏提示框
        setTimeout(()=>{
            context.commit('changeIsShowToast',{show:false})
        },1000)
        }
    },
}